<?php

namespace App\Http\Requests\V1;

/**
 * 忘记密码提交申请请求类
 *
 * Class ForgotPasswordCreateRequest
 * @package App\Http\Requests\V1
 */
class ForgotPasswordCreateRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return parent::authorize();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = parent::rules();
        $rules['code'] = 'bail|required|exists:admin_users,code,deleted_at,NULL';
        $rules['newpwd'] = 'bail|required|min:6|alpha_dash';
        return $rules;
    }

    /**
     * Get custom messages for validator errors.
     *
     * @return array
     */
    public function messages()
    {
        $messages = parent::messages();
        $messages['code.required'] = '登录账号不能为空';
        $messages['code.exists'] = '登录账号不存在';
        $messages['newpwd.required'] = '新密码不能为空';
        $messages['newpwd.min'] = '新密码不少于6个字符';
        $messages['newpwd.alpha_dash'] = '新密码必须由数字及字母组成';
        return $messages;
    }
}
